#pragma once
#include <string>
#include <cstring>
#include <cerrno>
#include "Log.hpp"

const std::string server_name = "server";
const std::string client_name = "client";
const char* func_types[] = {"Socket", "Bind", "Listen", 
                            "Accept", "Read", "Write", 
                            "Connect", "Unknow"};

void CheckRet(int ret, const std::string& pro_name, const std::string& func_name)
{
    if((func_name == "Write" || func_name == "Read") && ret == 0)
    {
        _log.LogMessage(ClassFile, Info
                        , "%s get zero\n", func_name.c_str());
        exit(-1);
    }
    else if(ret == -1)
    {
        _log.LogMessage(ClassFile, Error
                        , "%s %s error# errno : %d, strerror : %s\n"
                        , pro_name.c_str(), func_name.c_str()
                        , errno, strerror(errno));
        exit(-1);
    }
    else
         _log.LogMessage(ClassFile, Info, "%s %s success\n", pro_name.c_str(), func_name.c_str());
}



